﻿@model Module
@{
    ViewBag.Title = Model.Title;
    var entry = ContextManager.CurrentDb.Entry(Model);
    entry.Reference(m => m.Venue).Load();
    entry.Collection(m => m.Speakers).Load();
    entry.Reference(m => m.Level).Load();
    
    var user = ContextManager.CurrentUser;
    bool isRegistered = (user != null) ?
        user.Interop.IsRegisteredFor(Model.Id) : false;
}
<div class="mainDetails">
    @Html.Raw(Model.Description)

    @if (!Model.IsPast)
    {
        <h3>Local Accomodations</h3>
        @Html.Raw(Model.Venue.LocalAccommodations)
        <h3>Attend</h3>
        if (isRegistered)
        {
            <p>You are currently registered for this event. To manage your events, visit @Html.ActionLink("My Training", "Index", "My").</p>
        }
        else if (Cart.Current.InCart(Model))
        {
            <p>This event is currently in your cart. @Html.ActionLink("Check out now", "Index", "Cart").</p>   
        }
        else
        {
            <p>@Model.PriceString() @Html.ActionLink("Register Now", "AddModule", "Cart", new { id = Model.Id }, new { @class = "reg" })</p>
        }
    }
    else
    {
        <p><strong>Note:</strong> This module has expired and is no longer available for registration.</p>
    }
</div>
<div class="rightDetails">
    @Html.Partial("ModuleRightBar", Model)
    @Html.Partial("ListOfRelatedProducts", Model)

</div>
